package com.ingeniouscamel.springcxfws.client;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Before;
import org.junit.Test;
import org.springframework.util.Assert;

import com.ingeniouscamel.springcxfws.service.CalculatorService;

public class CalculatorWebServiceClientTest {
	private CalculatorService calculatorWebService;

	@Before
	public void setUp() throws Exception {
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
		factory.setServiceClass(CalculatorService.class);
		factory.setAddress("http://localhost:8080/SpringCxfWSApp/services/calculator");
		calculatorWebService = (CalculatorService) factory.create();
	}

	@Test
	public void testAddNumbers() {
		Assert.isTrue(calculatorWebService.addNumbers(3, 5) == 8);
	}

	@Test
	public void testSubtractNumbers() {
		Assert.isTrue(calculatorWebService.subtractNumbers(7, 4) == 3);
	}
}
